﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MathLab.Utils
{
  class MatrixTransposition
  {
    /// <summary>
    /// Transpose given matrix
    /// </summary>
    /// <param name="matrix"></param>
    /// <returns>Transposed matrix</returns>
    public static double[,] Transpose(double[,] matrix)
    {
      double [,] matrixResult = new double[matrix.GetLength(1),matrix.GetLength(0)];
      for (int i = 0; i < matrix.GetLength(0); i++)
      {
        for (int j = 0; j < matrix.GetLength(1); j++)
        {
          matrixResult[j, i] = matrix[i, j];
        }
      }
      return matrixResult;
    }
  }
}
